<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<h:form id="formExerciseGroupData" prependId="false" style="height:100%" >
		<h:panelGrid style="height:90%" columns="1" columnClasses="top-align" > 
			<h:column>
				<div style="display:block;height:90%;width:600px">
					<h:panelGrid columns="2" style="white-space:nowrap;"  > 
			            <h:outputLabel value="#{msgs.Name} :" for="exerciseGroupName" />
			            <p:inputText id="exerciseGroupName"     value="#{exerciseGroupBean.exerciseGroup.name}" maxlength ="20" size="20" 
			            	required="false" requiredMessage="#{msgs.ExerciseGroupNameObligatory}">
			            </p:inputText>
			            
						<h:outputText value="#{msgs.ModalityType}" style="white-space: nowrap;"/>
						<p:selectOneMenu value="#{exerciseGroupBean.exerciseGroup.trainingType}"  converter="#{genericConverter}"   label="#{msgs.ModalityTypes}" 
							required="true" requiredMessage="#{msgs.TrainingTypeObligatory}">
							<f:selectItem itemLabel="#{msgs.Select}" itemValue="#{null}" noSelectionOption="true"/>
			            	<f:selectItems value="#{exerciseGroupBean.trainingTypes}"  var="trainingType" itemLabel="#{msgs[trainingType.name]}" itemValue="#{trainingType}" />
							<p:ajax listener="#{exerciseGroupBean.changeFullTrainingTypes}" update="egmodalitySelect"  />
						</p:selectOneMenu> 
		
						<h:outputText  value="#{msgs.Modality}" />
						<p:selectOneMenu id="egmodalitySelect" value="#{exerciseGroupBean.exerciseGroup.modality}" converter="#{genericConverter}" label="#{msgs.Modalitys}" 
							required="true" requiredMessage="#{msgs.ModalityObligatory}">
							<f:selectItem itemLabel="#{msgs.Select}" itemValue="#{null}" noSelectionOption="true"/>
			            	<f:selectItems value="#{exerciseGroupBean.fullModalitys}"  var="modality" itemLabel="#{modality.name}" itemValue="#{modality}" />
							<p:ajax listener="#{exerciseGroupBean.changeEgModality}" update=":tabExerciseGroup:exercisesForm:exercisesTableSource"  />
						</p:selectOneMenu>					            
			            
			
						<h:outputLabel value="#{msgs.Description} :" for="exerciseGroupDescription" style="white-space:nowrap;"  />
						<p:inputTextarea id="exerciseGroupDescription" rows="4" cols="50"
							counter="counter" maxlength="180"
							counterTemplate="{0} #{msgs.CharsRemaining}" autoResize="false"
							value="#{ exerciseGroupBean.exerciseGroup.description}" />
						<p:spacer />
						<h:outputText id="counter" />

						<h:outputLabel value="#{msgs.Obs} :" for="exerciseGroupObs" />
						<p:inputTextarea id="exerciseGroupObs" rows="4" cols="50"
							counter="counterExerciseGroupObs" maxlength="180"
							counterTemplate="{0} #{msgs.CharsRemaining}" autoResize="false"
							value="#{ exerciseGroupBean.exerciseGroup.obs}" />
						<p:spacer />
						<h:outputText id="counterExerciseGroupObs" />
		
		
			            <h:outputText value="#{msgs.Status} :" />
			            <p:selectOneRadio value="#{exerciseGroupBean.exerciseGroup.active}" >
			                <f:selectItem itemLabel="#{msgs.Active}"  	itemValue="true"   />
			                <f:selectItem itemLabel="#{msgs.Inactive}"	itemValue="false" />
			            </p:selectOneRadio>
		
						<h:outputLabel 	value="#{msgs.CreatedAt} :"		for="exerciseGroupCreatedAt" rendered="#{exerciseGroupBean.exerciseGroup.id != null}"  />
						<p:inputText  	id="exerciseGroupCreatedAt" 	value="#{exerciseGroupBean.exerciseGroup.createdAt}" disabled="true" rendered="#{exerciseGroupBean.exerciseGroup.id != null}"  >
							<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
						</p:inputText>
		
						<h:outputLabel 	value="#{msgs.ChangedAt} :"		for="exerciseGroupChangedAt" rendered="#{exerciseGroupBean.exerciseGroup.id != null}" />
						<p:inputText  	id="exerciseGroupChangedAt" 	value="#{exerciseGroupBean.exerciseGroup.lastChange}" disabled="true" rendered="#{exerciseGroupBean.exerciseGroup.id != null}" >
							<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
						</p:inputText>
		
						<h:outputLabel 	value="#{msgs.ChangedBy} :"		for="exerciseGroupChangedBy" rendered="#{exerciseGroupBean.exerciseGroup.id != null}" />
						<p:inputText  	id="exerciseGroupChangedBy" 	value="#{exerciseGroupBean.exerciseGroup.changedBy.email}" disabled="true" rendered="#{exerciseGroupBean.exerciseGroup.id != null}" />
						
						<h:outputLabel 	value="#{msgs.Library} :"		for="exerciseGroupLibrary" />
						<p:selectOneMenu id="exerciseGroupLibrary" value="#{exerciseGroupBean.exerciseGroup.library}"	  disabled="#{exerciseGroupBean.exerciseGroup.id != null}" converter="#{libraryConverter}">
			            	<f:selectItems value="#{exerciseGroupBean.activeUser.librarys}" var="library" itemLabel="#{library.name}" itemValue="#{library}" />
						</p:selectOneMenu>

					</h:panelGrid>
				</div>
			</h:column>
		</h:panelGrid>			
		<div align="left"   >
			<p:commandButton  value="#{msgs.Save}"		action="#{exerciseGroupBean.saveExerciseGroup}"		
				ajax="true"	update=":content, :growl, :listExerciseGroupForm"		icon="ui-icon-disk"	rendered="#{exerciseGroupBean.exerciseGroup.id != null}" />
			<p:commandButton  value="#{msgs.Create}"	action="#{exerciseGroupBean.createExerciseGroup}"	
				ajax="true"	update=":content, :growl, :listExerciseGroupForm"		icon="ui-icon-document"	rendered="#{exerciseGroupBean.exerciseGroup.id == null}" />
			<p:spacer width="50px"/>	
			<p:commandButton   value="#{msgs.Cancel}" update=":content, :growl"	action="#{exerciseGroupBean.cancelChange}"	icon="ui-icon-cancel"/>
		</div>
	</h:form>
</html>